package com.wxw.tools;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 此功能处理MQTT的消息。
 * @author Dreams Wang
 *
 */
@Component
@Order(999)
public class RunMqtt  implements ApplicationRunner{

    @Autowired
	ClientMQTT client;
    
   // @Value("${mqtt.topic}")
   // String TOPIC;
    
   public void run(ApplicationArguments args) throws Exception {
    	
    	       int[] Qos1= new int[3];
    	  String[] topic = new String[3];
    	  
    	         Qos1[0] = 0;
    	        topic[0] = "Set/#";
    	         Qos1[1] = 2;
    	        topic[1] = "UserMsg/#"; 
    	         Qos1[2] = 0;
    	        topic[2] = "UserRec/#";
    	  client.subscribe(Qos1,topic);
    }


    
}
